/*
 * Copyright (c) 2001 Boris Pruessmann and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Common Public License v0.5
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors:
 *    Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.p4eclipse.core.syncinfo;

import java.io.Serializable;
import java.util.Date;

import net.sourceforge.p4eclipse.core.Policy;

/**
  * @version 	1.0
  * @author		<a href="mailto:bpruessmann@users.sourceforge.net">Boris Pruessmann</a>
  */
public class ResourceSyncInfo implements Serializable
{
	static final long serialVersionUID = -5903762684861295448L;

	public static final ResourceSyncInfo NULL_INFO = new ResourceSyncInfo(0x0000);
	
	public static final String ACTION_ADD    = "add";    //$NON-NLS-1$
	public static final String ACTION_DELETE = "delete"; //$NON-NLS-1$
	public static final String ACTION_EDIT   = "edit";   //$NON-NLS-1$

	private Integer magic = new Integer(0x0001);
	private String  action = "";         //$NON-NLS-1$
	private String  clientFileName = ""; //$NON-NLS-1$
	private String  depotFileName = "";  //$NON-NLS-1$
	private String  headAction = "";     //$NON-NLS-1$
	private String  headType = "";       //$NON-NLS-1$
	private Date    headTime = new Date();
	private Integer headRev = new Integer(0);
	private Integer headChange = new Integer(0);
	private Integer haveRev = new Integer(0);
	private Boolean resolved = Boolean.TRUE;

	public ResourceSyncInfo()
	{
	}
	
	private ResourceSyncInfo(int magic)
	{
		this.magic = new Integer(magic);
	}
	
	public int getMagic()
	{
		return magic.intValue();
	}

	/**
	 * Gets the action.
	 * @return Returns a String
	 */
	public String getAction()
	{
		return action;
	}

	/**
	 * Sets the action.
	 * @param action The action to set
	 */
	public void setAction(String action)
	{
		Policy.assertNotNull(action);
		this.action = action;
	}

	/**
	 * Gets the depotFileName.
	 * @return Returns a String
	 */
	public String getClientFileName()
	{
		return clientFileName;
	}

	/**
	 * Sets the depotFileName.
	 * @param depotFileName The depotFileName to set
	 */
	public void setClientFileName(String clientFileName)
	{
		Policy.assertNotNull(clientFileName);
		this.clientFileName = clientFileName;
	}


	/**
	 * Gets the depotFileName.
	 * @return Returns a String
	 */
	public String getDepotFileName()
	{
		return depotFileName;
	}

	/**
	 * Sets the depotFileName.
	 * @param depotFileName The depotFileName to set
	 */
	public void setDepotFileName(String depotFileName)
	{
		Policy.assertNotNull(depotFileName);
		this.depotFileName = depotFileName;
	}

	/**
	  * Gets the headAction.
	  */	
	public String getHeadAction()
	{
		return headAction;
	}
	
	/**
	  * Sets the headAction.
	  * @param headAction The headAction to set
	  */
	public void setHeadAction(String headAction)
	{
		Policy.assertNotNull(headAction);
		this.headAction = headAction;
	}
	
	/**
	 * Gets the headType.
	 * @return Returns a String
	 */
	public String getHeadType()
	{
		return headType;
	}

	/**
	 * Sets the headType.
	 * @param headType The headType to set
	 */
	public void setHeadType(String headType)
	{
		Policy.assertNotNull(headType);		
		this.headType = headType;
	}

	/**
	 * Gets the headRev.
	 * @return Returns a Integer
	 */
	public Integer getHeadRev()
	{
		return headRev;
	}

	/**
	 * Sets the headRev.
	 * @param headRev The headRev to set
	 */
	public void setHeadRev(Integer headRev)
	{
		Policy.assertNotNull(headRev);
		this.headRev = headRev;
	}

	/**
	 * Gets the headChange.
	 * @return Returns a Integer
	 */
	public Integer getHeadChange()
	{
		return headChange;
	}

	/**
	 * Sets the headChange.
	 * @param headChange The headChange to set
	 */
	public void setHeadChange(Integer headChange)
	{
		Policy.assertNotNull(headChange);		
		this.headChange = headChange;
	}

	/**
	 * Gets the haveRev.
	 * @return Returns a Integer
	 */
	public Integer getHaveRev()
	{
		return haveRev;
	}

	/**
	 * Sets the haveRev.
	 * @param haveRev The haveRev to set
	 */
	public void setHaveRev(Integer haveRev)
	{
		Policy.assertNotNull(haveRev);		
		this.haveRev = haveRev;
	}
	
	public Date getHeadTime()
	{
		return headTime;
	}
	
	public void setHeadTime(Date headTime)
	{
		Policy.assertNotNull(headTime);
		this.headTime = headTime;
	}

	public Boolean isResolved()
	{
		return resolved;
	}
	
	public void setResolved(Boolean resolved)
	{
		this.resolved = resolved;
	}

	public boolean isNull()
	{
		return magic.equals(NULL_INFO.magic);
	}	
}
